from src.conf.base_conf import BaseConf


class TimerTask(BaseConf):
    def __init__(self, path: str):
        """备份配置文件"""
        super().__init__(path)

    def _reload_from_dict(self, conf_dict: dict):
        self.content = conf_dict.get("定时任务", [{
            "启用": False,
            "每周": [1, 2, 3, 4, 5, 6, 7],
            "时间": ["02:01", "23:59"],
            "执行命令": ["chat 服务器将在30秒后备份", "wait 30", "startBak"]
        }])

    def _check(self):
        if type(self.content) is not list:
            self.robot_re_list = []
            print("[DLS][WARN] 定时任务格式异常！此功能将被禁用")

    def __str__(self) -> str:
        conf_dict = {"定时任务": self.content}
        return self._dict_to_str(conf_dict)
